package Text9;

import java.util.Scanner;

public class Main {
    static final int N = 100010;
    static int n;
    static long res;
    static int[] q = new int[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        for (int i = 0; i < n; i++) {
            q[i] = in.nextInt();
        }
        m_qsort(0, n - 1);
        System.out.print(res);
    }

    private static void m_qsort(int l, int r) {
        if (l >= r) {
            return;
        }
        int mid = l + r >> 1;
        m_qsort(l, mid);
        m_qsort(mid + 1, r);
        int k = 0, i = l, j = mid + 1;
        int[] tmp = new int[r - l + 1];
        while (i <= mid && j <= r) {
            if (q[i] <= q[j]) {
                tmp[k++] = q[i++];
            } else {
                tmp[k++] = q[j++];
                res += mid - i + 1;
            }
        }
        while (i <= mid) {
            tmp[k++] = q[i++];
        }
        while (j <= r) {
            tmp[k++] = q[j++];
        }
        for (int m = 0; m < tmp.length; m++) {
            q[l + m] = tmp[m];
        }
    }
}
